CX_CONDITIONED_BAG
Class hierarchy
Description:
This class manages "If...then" relationships in a table. A table entry consists of a condition ("If") and an object assigned to it ("Then"). An entry is managed with a formula condition.
When the table is evaluated, the object whose assigned condition is fulfilled is delivered. I.e. in this case the table behaves like a kind of switch .
Example:
If... | Then... |
---|---|
Order quantity < 50 & customer = "Meier" | Discount = 6% |
Orderquantity < 50 | Discount = 5% |
Orderquantity < 100 | Unit price = DM 49.89 |
Order quantity >= 100 | Discount = 8% |
In the example, a price table containing special customer discounts is shown. Here, the customer "Meier" receives a special discount of "6%" for order quantities of less than 50 units. If, on the other hand, the customer "Müller" orders a quantity of 25 units, "5%" is returned as a discount.
It should also be noted that the individual entries can also deliver different objects. For example, if the order quantity is between 50 and 100, a unit price of "49.89 DM" is agreed, so that the returned object is not a percentage, but a value .
Code example:
Eine bedingte Objekttabelle besteht aus einer Menge von Formel-Bedingungen. Es gibt folgende Möglichkeiten, um einen neuen Eintrag in die Tabelle zu stellen.
1. Erzeugen einer Formel-Bedingung und Einfügen dieser in die Tabelle:
Var(fcond)CreateTransObject(CX_FCONDITION) -> fcond
"Bestellmenge < 50 & Kunde = \"Meier\"" fcond Put
. . . // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
// Objekt "o" an die Bedingung binden
o fcond SetReference(_object)
Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
// Einfügen in die Tabelle
fcond table Insert
2. Direkte Übergabe der Bedingung als Text und des zugehörigen Objektes "o" an die Tabelle, die keine Spaltenaufteilung besitzt.
Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
. . . // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
// Einfügen in die Tabelle
"Bestellmenge < 50 & Kunde = \"Meier\"" o table Insert
3. Direkte Übergabe der Bedingung als Text und des zugehörigen Objektes "o" an die Tabelle, wobei eine Spaltenaufteilung für die Tabelle definiert ist und die Bedingung dementsprechend aufgeteilt ist. Die einzelnen Bestandteile müssen dabei mit einem "Und" (= "&") verknüpft sein.
Var(table) CreateTransObject(CX_CONDITIONED_BAG) -> table
"Bestellmenge, Kunde" table Put
. . . // Erzeugen des Objektes "o", das an die Bedingung gebunden ist
// Format: expr (=Rest) Kunde Bestellmenge Objekt
"" "Meier" "<50" o table Insert
// Alternativ kann statt "Meier" auch "=Meier" geschrieben werden
Note: Instead of an entry, a vector of entries can be passed to the table for insertion.
Display on screen
An object box provides the functionality to display the individual entries of a conditional object table. An example display is shown in the following graphic (programme code and further notes):
In this example, the column division options have been used to make the display clearer.
Function | MA* | Parameter | Return | Short description |
---|---|---|---|---|
AddColVar | STRING. | Add a new column to the defined ones | ||
Amount | OBJECT | Return the value of the first object whose condition is met. | ||
ColVarNames | VECTOR&lmt;STRING> | Returning the column names | ||
ColVarNumbers | VECTOR&lmt;INTEGER> | Returning the column numbers | ||
ColVarTypes | VECTOR&lmt;INTEGER> | Return of the column types | ||
Delete | OBJECT. | Delete formula condition from the table | ||
Evaluate | OBJECT | Return the first object whose condition is met. | ||
Exchange | ||||
FindAll | COLL | Return all formula-condition objects | ||
First | OBJECT | |||
GetInputAccessPaths 233188 | VECTOR&lmt;STRING> | Return all access ports in a vector. | ||
GetInputVarNames | OBJECT. | VECTOR&lmt;STRING> | Return all variable names in a vector. | |
InsertAfter | OBJECT, OBJECT | |||
InsertBefore | ||||
InsertFirst | OBJECT | |||
InsertLast | OBJECT | |||
Last | OBJECT | |||
NColumnVars | INTEGER | Determine number of columns | ||
Pick | OBJECT | Return the first object whose condition is met. | ||
Pick via access expression | Return the first object whose condition is fulfilled. | |||
Query | COLL | Return all objects whose condition is fulfilled | ||
RemoveColVar | STRING. | Remove a column from the defined ones | ||
Repair | removes objects that are NOT formula condition objects (CX_FCONDITION) from the table. | |||
Revert | Reverses the order of the elements (CX_FCONDITIONE objects). | |||
SanityCheck | INTEGER | Check consistency of the table | ||
Add | CX_AMOUNT | CX_AMOUNT | Operator + as function | |
AddAssign | CX_AMOUNT | operator += as function | ||
AmountWeak | ||||
Autoformat | INTEGER, INTEGER | CX_AMOUNT | Returns an object formatted according to the given number of digits before and after the decimal point (only for CX_VALUE, otherwise the object itself). | |
DivAssign | CX_AMOUNT | Operator /= as a function | ||
Divide | CX_AMOUNT | CX_AMOUNT | Operator / as function | |
MulAssign | CX_AMOUNT | operator *= as function | ||
Multiply | CX_AMOUNT | CX_AMOUNT | Operator * as a function | |
string | INTEGER | CX_STRING | Returns the string representation of the object. | |
SubAssign | CX_AMOUNT | Operator -= as function | ||
Subtract | CX_AMOUNT | CX_AMOUNT | Operator - as a function |
* MA = member access function
Data field | Type | Reference class | I* | Brief description |
---|---|---|---|---|
this | CX_CONDITIONED_BAG | The conditional object table | ||
flags | SHORT / INTEGER (?) | Controlling the evaluation via flags |
I = Indexable data field
Module | Brief description |
---|---|
testform.mod | Test formula |
columvar.mod | Table column editing module |
cxConditionedBag.mod | Tables base module |
PriceDiscountTable.mod | Price tables base module |